<template>
  <div>
    <van-tabs v-model="active" @click="qiehuan(active)">
      <van-tab v-for="v in brotherCategory" :key="v.id" :title="v.name">
        <div class="wenzi">
          <h2>{{ v.name }}</h2>
          <p>{{ v.front_name }}</p>
        </div>
      </van-tab>
    </van-tabs>
    <div class="big_long">
      <ul>
        <li v-for="v in data" :key="v.id" @click="$router.push('/goodsDetail/'+v.id)">
          <img :src="v.list_pic_url" alt="" width="100%" />
          <h4>{{ v.name }}</h4>
          <p>{{ v.retail_price | fun_qian}}</p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { GetJujia_In, GetS_ShowListData } from "@/request/api";
export default {
  data() {
    return {
      active:'',
      id: "",
      brotherCategory: "",
      data: "",
    };
  },
  methods: {
    qiehuan(v) {
      this.id = this.brotherCategory[v].id;
      GetS_ShowListData({ categoryId: this.id }).then((res) => {
        this.data = res.data.data;
      });
    },
  },
  filters: {
    fun_qian(v) {
      let num = v.toFixed(2);
      return "￥" + num + "元";
    },
  },
  created() {
    this.id = this.$route.params.id;
    this.active = this.$route.params.i;
    // console.log(this.$route.params.i);
    console.log( this.$route.params);
    
    GetJujia_In({ id: this.id }).then((res) => {
      console.log(res);
      this.brotherCategory = res.data.brotherCategory;
    });
    GetS_ShowListData({ categoryId: this.id }).then((res) => {
      // console.log(res);
      this.data = res.data.data;
    });
  },
  components: {},
};
</script>

<style lang="less" scoped>
.wenzi {
  width: 100%;
  height: 0.9rem;
  text-align: center;
  // background-color: pink;
  overflow: hidden;
  h2 {
    margin-top: 0.2rem;
    font-size: 0.2rem;
  }
  p {
    margin-top: 0.25rem;
    font-size: 0.15rem;
  }
}

.big_long {
  background-color: #fff;
  width: 100%;
  min-height: 100%;
}
.big_long ul {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
}
.big_long ul li {
  width: 49%;
  min-height: 100%;
  margin-top: 10px;
}
.big_long ul li h4,
.big_long ul li p {
  width: 100%;
  text-align: center;
  margin-bottom: 10px;
}
.big_long ul li p {
  color: #8b0000;
}
</style>
